package com.huntkey.controller;

import org.elasticsearch.action.get.GetResponse;
import org.elasticsearch.client.transport.TransportClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HelloController {
	
	@Autowired
	private TransportClient client;
	
	@RequestMapping("/blogInfo")
	public String getBlogInfo(){
		//搜索数据
        GetResponse response = client.prepareGet("blog", "article", "1").execute().actionGet();
        //输出结果
        System.out.println(response.getSourceAsString());
        //关闭client
        client.close();
		return response.getSourceAsString();
	}
	
}
